package com.hong.service;

import org.springframework.aop.framework.AopContext;

/**
 * <br>AOP:同一对象内的嵌套方法调用拦截失效</br>
 *
 * @author 533735
 * @version 1.0
 * @email wanghong3@dafycredit.com
 * @date 2018/11/6 17:40
 * @since 1.0
 */
public class NestableInvocationService {
    public void method1(){
        //method2();
        //解决嵌套调用拦截失效,让目标对象依赖它的代理对象
        //<aop:aspectj-autoproxy expose-proxy="true"/>
        ((NestableInvocationService)AopContext.currentProxy()).method2();
        System.out.println("method1 executed!");
    }

    public void method2(){
        System.out.println("method2 executed!");
    }
}
